<?php

defined('BASEPATH') or exit('No direct script access allowed');

/**
 * Test Model
 * 
 * @author      Nguyen Hai Dang - Gidaff Dev Team
 * @package 	GiCMS
 * @subpackage  TEST Module
 * @category	Module
 */
class Test_m extends MY_Model {

    var $_table = 'test1';
//    var $dojo_store = array(
//        'test2_id' => array(            
//            'join' => array(
//                'test2' => 'test1.test2_id = test2.id'
//        )
//    );
//    );
    var $dojo_fields = array(
        'title' => array(
            'format' => TYPE_TEXT,
            'label_key' => 'test:title'
        ),
        'meo' => array(
            'format' => TYPE_TEXT,
            'label_key' => 'test:meo'
        ),
        'description' => array(
            'format' => TYPE_TEXTAREA,
            'label_key' => 'test:description',
            'require_lang' => 1
        ),
        'test2_id' => array(
            'format' => TYPE_SELECT,
            'edit_able' => 1,
            'label_key' => 'test:test2',
            'store' => array(
                'from' => 'test2',
                'join' => array(                    
                    'test3' => 'test2.test3_id = test3.id'
                ),
                'fields' => 'test2.id, CONCAT(test2.name,"-------",test3.text_color,test3.bg_color) as name'
            )            
        ),
        'status' => array(
            'format' => TYPE_RADIO,
            'label_key' => 'test:active',
            'options' => array(
                1 => 'test:Hang moi', 2 => 'test:Hang second hand', 3 => 'test:Hang xach tay', 
            )            
        ),
        'date_order' => array(
            'format' => TYPE_DATETIME,
            'label_key' => 'test:Date order',
            'dojo_props' => 'constraints:{datePattern:"dd-MM-yyyy", strict:true}'
        ),
        'zone' => array(
            'format' => TYPE_CHECKBOX,
            'label_key' => 'test:zone',
        ),
        'price' => array(
            'format' => TYPE_CURRENCY,
            'label_key' => 'test:price',
            'dojo_props' => 'required:true,currency:"VND",value:5444775, constraints:{pattern:"##,### ¤",round:"2"}'
        ),
        'test4' => array(
            'grid_join' => array(
               'test4' => 'test1.test4 = test4.id'
           )          
        ));
        
       var dojo_grid = array(
           'fields' => 'id, title, test2_id, status, price, test4'
           'join' => array(
               'test4' => 'test1.test4 = test4.id'
           )                      
       );
    );

    function __construct() {
        parent::__construct();
        $this->dojo_fields['zone']['options'] = array(
            1 => 'test:Vung 1', 2 => 'test:Vung 2', 3 => 'test:Vung 3', 
        );
        
        $this->before_create = array('acc');
        
    }

    function acc($data) {
        $data['meo'] .= ' --> CON MEO';
        return $data;
    }
    
    
}

/* End of file models/email_templates_m.php */